package framework.objects;

import javax.microedition.khronos.opengles.GL10;

import android.graphics.Rect;
import framework.GameCamera;
import framework.graphics.Presentation;

public abstract class GameObject implements Drawable {
	
	protected float x = -1000;
	protected float y = -1000;	
	protected int height = 0;
	protected int width = 0;	
	protected boolean alive = true;
	
	protected Presentation presentation;
	
	public GameObject() {
		initPresentation();
		initSize();
	}
	
	public boolean isAlive() {
		return alive;
	}
	
	public void setAlive(boolean alive) {
		this.alive = alive;
	}
	
	protected abstract void initPresentation();
	
	protected void initSize() {
		if (presentation != null) {
			height = (int) presentation.getHeight();
			width = (int) presentation.getWidth();
		}
	}
	
	public void draw(GL10 gl, float deltaTime) {
		if (presentation != null) {
			presentation.draw(deltaTime, gl, x - width/2, y - height/2);
		}
	}
	
	public Rect getRect() {
		return new Rect((int)x - width/2, (int)y - height/2, (int)x + width/2, (int)y + height/2);
	}
	
	public float getScreenX() {
		return x - GameCamera.X;
	}
	
	public float getScreenY() {
		return y - GameCamera.Y;
	}
	
}
